package com.ncp.model.biz.order;

import java.util.ArrayList;
import java.util.List;

import com.ncp.model.dao.DB;
import com.ncp.model.dao.DbConnection;

public class HandleOrderInfoBiz {
	DB common = new DB();
	
	/*
	 * 当用户完成支付功能后，更新OrderBasic表中的字段
	 * @param OrderStatus、TradeID、BuyerAccount
	 * @return
	 * */
	public int updateOrderInfoPay(int userID, String orderID, String orderStatus, String tradeID, String buyerAccount){
		int result = 0;
		String sql = "update ORDERBASIC set OrderStatus=?,TradeID=?,BuyerAccount=? where OrderID=? and UserID=?";
		common.setSql(sql);
		common.setConn(DbConnection.getConnByDataSource());
		List<Object> list = new ArrayList<Object>();
		list.add(0, orderStatus);
		list.add(1, tradeID);
		list.add(2, buyerAccount);
		list.add(3, orderID);
		list.add(4, userID);
		common.setList(list);
		result = common.executeUpdate();
		return result;
	}
	
	/*
	 * 修改订单状态
	 * 当商家发货后，将订单状态修改为WAIT_BUYER_CONFIRM_GOODS
	 * 买家确认收货完成交易后，将订单状态修改为TRADE_FINISHED
	 * */
	public int updateOrderStatus(int userID, String orderID, String orderStatus){
		int result = 0;
		String sql = "update ORDERBASIC set OrderStatus=? where OrderID=? and UserID=?";
		common.setSql(sql);
		common.setConn(DbConnection.getConnByDataSource());
		List<Object> list = new ArrayList<Object>();
		list.add(0, orderStatus);
		list.add(1, orderID);
		list.add(2, userID);
		common.setList(list);
		result = common.executeUpdate();
		return result;
	}
}
